package io.gitee.devaper.starlight.module.user.controller

import io.gitee.devaper.starlight.common.entity.vo.*
import io.gitee.devaper.starlight.security.*
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/user")
open class UserController {

    @GetMapping
    open fun info(): ApiResult<UserVO> {
        val details = SecurityContextHolder.getContext()
            .authentication.principal as DefaultUserDetails
        return ApiResult.success(data = UserVO.valueOf(details.user))
    }

}